<!DOCtype html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/Dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>{$Think.lang.manageName}</title>
        <link href="../Public/Css/style.css" rel="stylesheet" type="text/css">
        <!--                       Javascripts                       -->
        <!-- jQuery -->
        <script type="text/javascript" src="../Public/Js/jquery-1.3.2.min.js"></script>
        <script type="text/javascript" src="../Public/Js/jquery.form.js"></script>
        <style type="text/css">
            body {background:url(../Public/Images/bodyBg.jpg) repeat-x #E4E9FD;}
            .text_font {font-size:13px; color:#fff;}
            .none {display:none;}
            .red {color:red;}
            .blue {color:blue;}
        </style>
    </head>
    <body onload="fleshVerify()">
        <table width="715" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td height="130">&nbsp;</td>
            </tr>
            <tr>
                <td height="314" valign="top" background="../Public/Admin/Images/login01.gif">
                    <form id="loginForm"  name="add" method="post" action="{:U('Admin-Public/checklogin')}">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width="57%" height="150">&nbsp;</td>
                                <td width="43%">&nbsp;</td>
                            </tr>
                            <tr>
                                <td height="115" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td width="24%" height="18">&nbsp;</td>
                                            <td width="76%">&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td height="62">&nbsp;</td>
                                            <td valign="top"><img src="../Public/Admin/Images/login03.gif" width="222" height="48" /></td>
                                        </tr>
                                    </table></td>
                                <td valign="top"><table width="94%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td width="20%" height="24" valign="middle" class="text_font">{$Think.lang.username}：</td>
                                            <td width="54%" valign="middle"><input name="username" type="text" class="input" id="username" size="16" maxlength="20" /></td>
                                            <td width="26%" rowspan="3" align="left" valign="bottom"><input type="image" name="Submit" id="submit_form" onclick="" src="../Public/Admin/Images/login04.gif" /></td>
                                        </tr>
                                        <tr valign="middle">
                                            <td height="24" class="text_font">{$Think.lang.password}：</td>
                                            <td><input name="password" type="password" class="input" id="password" size="16" maxlength="20" /></td>
                                        </tr>
                                        <tr valign="middle">
                                            <td height="24" class="text_font">{$Think.lang.verify}：</td>
                                            <td><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td width="17%" height="18" align="right" valign="middle"><a href="javascript:void(0)" onclick="javascript:fleshVerify();"><img src="" title="{$Think.lang.cannotsee}" id="verifyimg" width="48" height="22" align="absmiddle" alt="{$Think.lang.verify}" /></a></td>
                                                        <td><input name="verify" id="verify" type="text" class="input" id="pass" size="4" maxlength="4" /></td>
                                                    </tr>
                                                </table></td>
                                        </tr>
                                        <tr valign="middle">
                                            <td height="24"></td>
                                            <td height="2" colspan="2" class="text_font" id="result"></td>
                                        </tr>
                                        <tr valign="middle">
                                            <td height="6" width="272" colspan="3"></td>
                                        </tr>
                                    </table></td>
                            </tr>
                        </table>
                    </form></td>
            </tr>
            <tr>
                <td height="4"></td>
            </tr>
        </table>
        <script type="text/javascript" language="javascript">
            function prepareLogin()
            {
                var username = $("#username").val();
                var password = $("#password").val();
                var verify = $('#verify').val();
                if(username=="") {
                    setstyle('<img alt="" src="../Public/Admin/Images/icons/cross.png" /> <span class="red">请填写用户名</span>');
                    return false;
                } else if (password=="") {
                    setstyle('<img alt="" src="../Public/Admin/Images/icons/cross.png" /> <span class="red">请填写密码</span>');
                    return false;
                } else if (verify=="") {
                    setstyle('<img alt="" src="../Public/Admin/Images/icons/cross.png" /> <span class="red">请填写验证码</span>');
                    return false;
                } else {
                    setstyle('<img alt="" src="../Public/Admin/Images/icons/loading.gif" /> <span class="blue">正在提交....</span>');
                }
            }

            function processResponse(data)
            {
                data=eval('('+data+')');
                $("#result").removeClass("none");
                if(data.status == 1)
                {
                    $("#result").html('<span style="color:blue;">登錄成功！正在跳轉～</span>');
                    window.location = "{:U("Admin-Index/index")}";
                }else{
                    //                    switch(data.status){
                    //                        case -1:
                    //                            document.login.verify.select();
                    //                            break;
                    //                        case -2:
                    //                            document.login.username.select();
                    //                            break;
                    //                    }
                    fleshVerify();
                    $("#result").html(data.info);
                    $("#result").addClass("errorMessage");
                    setTimeout("removestyle()", 2500);
                }
            }

            function setstyle(html_s) {
                $("#result").removeClass("none");
                $("#result").html(html_s);
            }

            function removestyle() {
                $("#result").addClass("none");
            }
            function fleshVerify(){ //重載驗證碼
                var timenow = new Date().getTime();
                $('#verify').attr("value","");
                $('#verifyimg').attr("src","{:U('Admin-Public/verify',array('h'=>'1'))}&ts="+timenow+"");
            }
            var options = {
                beforeSubmit: prepareLogin,
                success: processResponse,
                datatype: 'json'
            };
            $('#loginForm').ajaxForm(options);
            $('#loginForm').submit(function() {
                $(this).ajaxSubmit();
                return false;
            });
        </script>
    </body>
</html>

